package com.cropdoctor.util;

import com.alibaba.fastjson.JSONObject;
import com.github.kevinsawicki.http.HttpRequest;

import java.util.Map;

/**
 * @description: Httprequest工具类
 **/
public class Httprequest {

    /**
     * @description: http请求--post请求
     */
    public static JSONObject post(String url, Map<String, Object> data){
        HttpRequest httpRequest = new HttpRequest(url, "POST");
        httpRequest.form(data);
        return JSONObject.parseObject(httpRequest.body());
    }


    /**
     * @description: http请求--get请求
     */
    public static JSONObject get(String url){
        return JSONObject.parseObject(HttpRequest.get(url).body());
    }
}

